package cn.edu.dutir.indri.query;

import cn.edu.dutir.corpus.Topic;
import cn.edu.dutir.corpus.TopicHandler;

public abstract class Object2IndriQuery<E extends Topic> implements
		TopicHandler<E> {

	private TopicHandler<IndriQuery> mIndriHandler = null;

	public Object2IndriQuery(TopicHandler<IndriQuery> indriHandler) {
		mIndriHandler = indriHandler;
	}

	public abstract IndriQuery indriQuery(E input);

	@Override
	public void handle(E input) {
		IndriQuery indriQuery = indriQuery(input);
		mIndriHandler.handle(indriQuery);
	}

	public void close() {
		if (mIndriHandler != null) {
			mIndriHandler.close();
		}
	}
}
